import React, { useEffect, useState } from 'react'
import './index.scss'
import NavBar from '../../../components/nav-bar'
import qs from 'qs'
import axios from '../../../utils/axios'

export default function RoomDetail() {
  const { friendid, username, groupid, groupName } =
    qs.parse(window.location.search, { ignoreQueryPrefix: true }) || {}
  const [groupMember, setGroupMember] = useState([])
  let type
  if (friendid) {
    type = 'friend'
  } else if (groupid) {
    type = 'group'
  }
  useEffect(() => {
    // 获取好友信息
    axios.get(`/group/getGroupDetail?groupid=${groupid}`).then((res) => {
      setGroupMember(res.data?.data)
      console.log(res.data?.data)
    })
  }, [friendid, groupid])
  const rightClick = () => {
    if (type === 'group') {
    }
  }
  return (
    <div className="info-detail">
      <NavBar
        roomName={'详情'}
        rightClick={rightClick}
        showRight={false}
      ></NavBar>
      {groupMember &&
        groupMember.map((item, index) => (
          <div key={item.userid} className="info-detail-card">
            <img alt="--" src={item.avatar}></img>
            <div>{item.username}</div>
            {/* <div>{item.userid}</div> */}
          </div>
        ))}
    </div>
  )
}
